<?php

foreach ($posts as $post) {
    echo '<div class="corgi_feed_well">';
    echo '<div class="individual_feed_item">';
    echo '<div class="feed_item">';
    echo '<div class="feed_body">';
    echo '<div class="row">';
    echo '<div class="feed_profile_pic">';
    echo '<img src="' . base_url() . 'uploads/avatar/' . $post['p_avatar'] . '" alt="meta image" class="meta_image" />';
    echo '</div>';
    echo '<div class="feed_text">';
    echo '<p>' . $post['post'] . '</p>';
    echo '</div>';
    echo '</div>';
    echo '</div>';

    if (array_key_exists($post['postId'], $comments)) {
        foreach ($comments[$post['postId']] as $comment) {
            echo '<div class="comment_area">';
            echo '<p>' . $comment['comment'] . '</p>';
            echo '<form method="post" action="' . base_url() . 'doComment">';
            echo '<textarea name="comment" rows="3" class="span6"></textarea><br/>';
            echo '<input type="submit" name="doComment" value="موافق" class="btn" />';
            echo '<input type="hidden" name="postId" value="' . $post['postId'] . '"/>';
            echo '<input type="hidden" name="current_url" value="' . /* basename($_SERVER['PHP_SELF']) */current_url() . '"/>';
            echo '</form>';
            echo '</div>';
        }
    } else {
        echo '<div class="comment_area">';
        echo '<form method="post" action="' . base_url() . 'doComment">';
        echo '<textarea name="comment" rows="3" class="span6"></textarea><br/>';
        echo '<input type="submit" name="doComment" value="موافق" class="btn" />';
        echo '<input type="hidden" name="postId" value="' . $post['postId'] . '"/>';
        echo '<input type="hidden" name="current_url" value="' . /* basename($_SERVER['PHP_SELF']) */current_url() . '"/>';
        echo '</form>';
        echo '</div>';
    }

    echo '<hr class="feed_hr" />';
    echo '<div class="bottom_meta">';
    echo '<div class="row">';
    $this->load->view('./template/leftBottom');
    echo '<div class="bottom_right">
    <a href="#"></a> <span>|</span> <a href="#" class="show_comment_link">تعليق</a> <span>|</span> ' . $post['date'] . '
    </div> ';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
}
?>
   